/*
  学习目标：组件性能优化-使用PureComponent
*/
import React from 'react';

export default class App extends React.Component {
  state = {
    list: [{ id: 1 }, { id: 2 }],
  };

  handleClick = () => {
    // this.setState({ count: this.state.count + 1 });
    this.state.list[0].id = 3;
    this.setState(this.state);
  };

  render() {
    return (
      <div>
        <h1>数量： {this.state.count}</h1>
        <button onClick={this.handleClick}>点我修改list</button>
        <Footer list={this.state.list}></Footer>
      </div>
    );
  }
}

class Footer extends React.PureComponent {
  render() {
    console.log('render执行了  ----->  ');
    // console.log('render执行了Footer  ----->  ');
    return <div>我是子组件</div>;
  }
}
